package com.jumptap.adtag.utils;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.location.Location;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Build;
import android.os.Build.VERSION;
import android.provider.Settings.Secure;
import android.telephony.TelephonyManager;
import android.util.Log;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.security.MessageDigest;
import java.util.Enumeration;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class JtAdManager
{
  private static final String CHAR_SET = "iso-8859-1";
  private static final String CONNECTION_TYPE_EDGE = "edge";
  private static final String CONNECTION_TYPE_WIFI = "wifi";
  private static final String CONNECTION_TYPE__3G = "3g";
  public static final String JT_AD = "JtAd";
  public static final String JT_NAMRSPACE = "http://www.jumptap.com/lib/android";
  private static final int NETWORK_TYPE_CDMA = 4;
  private static final int NETWORK_TYPE_EVDO_0 = 5;
  private static final int NETWORK_TYPE_EVDO_A = 6;
  private static final int NETWORK_TYPE_HSDPA = 8;
  private static final int NETWORK_TYPE_HSPA = 10;
  private static final int NETWORK_TYPE_HSUPA = 9;
  private static final int NETWORK_TYPE_IDEN = 11;
  private static final int NETWORK_TYPE_RRT = 7;
  private static final String PREF_NAME = "jtPref";
  private static final String SHA1_ALGORITHM = "SHA-1";
  private static String procVersionStr = null;
  private boolean testMode = false;

  public static String SHA1(String paramString)
  {
    if (paramString == null)
      return null;
    try
    {
      MessageDigest localMessageDigest = MessageDigest.getInstance("SHA-1");
      new byte[40];
      localMessageDigest.update(paramString.getBytes("iso-8859-1"), 0, paramString.length());
      String str = convertToHex(localMessageDigest.digest());
      return str;
    }
    catch (Exception localException)
    {
      Log.i("JtAd", "Error generating generating SHA-1: ", localException);
    }
    return null;
  }

  private static String convertToHex(byte[] paramArrayOfByte)
  {
    StringBuffer localStringBuffer = new StringBuffer();
    int i = 0;
    int j;
    if (i < paramArrayOfByte.length)
      j = 0xF & paramArrayOfByte[i] >>> 4;
    int m;
    label94: for (int k = 0; ; k = m)
    {
      if ((j >= 0) && (j <= 9))
        localStringBuffer.append((char)(j + 48));
      while (true)
      {
        j = 0xF & paramArrayOfByte[i];
        m = k + 1;
        if (k < 1)
          break label94;
        i++;
        break;
        localStringBuffer.append((char)(97 + (j - 10)));
      }
      return localStringBuffer.toString();
    }
  }

  public static String getAndroidModel()
  {
    return Build.DEVICE;
  }

  public static String getBrand()
  {
    return Build.BRAND;
  }

  public static String getConnectionType(Context paramContext)
  {
    String str = "";
    ConnectivityManager localConnectivityManager = getConnectivityManager(paramContext);
    int i;
    int j;
    if (localConnectivityManager != null)
    {
      NetworkInfo localNetworkInfo = localConnectivityManager.getActiveNetworkInfo();
      if (localNetworkInfo != null)
      {
        i = localNetworkInfo.getType();
        j = localNetworkInfo.getSubtype();
        if (i != 1)
          break label73;
        str = "wifi";
      }
    }
    while (true)
    {
      Log.i("JtAd", "connectionType=" + str);
      return str;
      label73: if (i == 0)
        str = getConnectionTypeByNetSubtype(j);
    }
  }

  private static String getConnectionTypeByNetSubtype(int paramInt)
  {
    String str = "";
    if ((paramInt == 3) || (paramInt == 7) || (paramInt == 8) || (paramInt == 10) || (paramInt == 9) || (paramInt == 5) || (paramInt == 6))
      str = "3g";
    if ((paramInt == 1) || (paramInt == 2) || (paramInt == 4) || (paramInt == 11))
      str = "edge";
    return str;
  }

  private static ConnectivityManager getConnectivityManager(Context paramContext)
  {
    if (paramContext.checkCallingOrSelfPermission("android.permission.ACCESS_NETWORK_STATE") == 0)
      try
      {
        ConnectivityManager localConnectivityManager = (ConnectivityManager)paramContext.getSystemService("connectivity");
        return localConnectivityManager;
      }
      catch (SecurityException localSecurityException)
      {
        Log.e("JtAd", "JtAdManager.getConnectivityManager: " + localSecurityException.getMessage());
        return null;
      }
    Log.e("JtAd", "JtAdManager: Requires ACCESS_NETWORK_STATE permission");
    return null;
  }

  public static String getHID(Context paramContext)
  {
    return Settings.Secure.getString(paramContext.getContentResolver(), "android_id");
  }

  public static String getHIDSHA1(Context paramContext)
  {
    return SHA1(getHID(paramContext));
  }

  public static String getIPAddress()
  {
    String str = null;
    if (0 == 0)
      str = getLocalIpAddress();
    return str;
  }

  public static String getKernelVersion()
  {
    if (procVersionStr == null)
    {
      Matcher localMatcher;
      try
      {
        BufferedReader localBufferedReader = new BufferedReader(new FileReader("/proc/version"), 256);
        try
        {
          String str1 = localBufferedReader.readLine();
          localBufferedReader.close();
          localMatcher = Pattern.compile("\\w+\\s+\\w+\\s+([^\\s]+)\\s+\\(([^\\s@]+(?:@[^\\s.]+)?)[^)]*\\)\\s+\\([^)]+\\)\\s+([^\\s]+)\\s+(?:PREEMPT\\s+)?(.+)").matcher(str1);
          if (!localMatcher.matches())
          {
            Log.e("JtAd", "Regex did not match on /proc/version: " + str1);
            return "Unavailable";
          }
        }
        finally
        {
          localBufferedReader.close();
        }
      }
      catch (IOException localIOException)
      {
        Log.e("JtAd", "IO Exception when getting kernel version for Device Info screen", localIOException);
        return "Unavailable";
      }
      if (localMatcher.groupCount() < 4)
      {
        Log.e("JtAd", "Regex match on /proc/version only returned " + localMatcher.groupCount() + " groups");
        return "Unavailable";
      }
      procVersionStr = localMatcher.group(1);
      String str2 = procVersionStr;
      return str2;
    }
    return procVersionStr;
  }

  private static String getLocalIpAddress()
  {
    try
    {
      InetAddress localInetAddress;
      do
      {
        Enumeration localEnumeration1 = NetworkInterface.getNetworkInterfaces();
        Enumeration localEnumeration2;
        while (!localEnumeration2.hasMoreElements())
        {
          if (!localEnumeration1.hasMoreElements())
            break;
          localEnumeration2 = ((NetworkInterface)localEnumeration1.nextElement()).getInetAddresses();
        }
        localInetAddress = (InetAddress)localEnumeration2.nextElement();
      }
      while (localInetAddress.isLoopbackAddress());
      String str = localInetAddress.getHostAddress().toString();
      return str;
    }
    catch (SocketException localSocketException)
    {
      Log.e("JtAd", "JtAdManager.getLocalIpAddress:" + localSocketException.toString());
    }
    return null;
  }

  public static String getLocation(Context paramContext)
  {
    JtLocation.init(paramContext);
    Location localLocation = JtLocation.getCurrentLocation();
    String str = null;
    if (localLocation != null)
      str = localLocation.getLatitude() + "," + localLocation.getLongitude();
    return str;
  }

  public static String getManufacturer()
  {
    return "";
  }

  public static String getNetworkType(Context paramContext)
  {
    String str = "";
    TelephonyManager localTelephonyManager = getTelephonyManager(paramContext);
    if (localTelephonyManager != null);
    switch (localTelephonyManager.getNetworkType())
    {
    default:
      str = "";
      return str;
    case 1:
      return "GPRS";
    case 2:
      return "EDGE";
    case 3:
    }
    return "UMTS";
  }

  public static String getOperatorName(Context paramContext)
  {
    TelephonyManager localTelephonyManager = getTelephonyManager(paramContext);
    String str = "";
    if (localTelephonyManager != null)
      str = localTelephonyManager.getNetworkOperatorName();
    return str;
  }

  public static String getPhoneType(Context paramContext)
  {
    String str = "";
    TelephonyManager localTelephonyManager = getTelephonyManager(paramContext);
    if (localTelephonyManager != null);
    switch (localTelephonyManager.getPhoneType())
    {
    default:
      str = "";
      return str;
    case 1:
    }
    return "GSM";
  }

  public static String getPreferences(Context paramContext, String paramString1, String paramString2)
  {
    return paramContext.getSharedPreferences("jtPref", 0).getString(paramString1, paramString2);
  }

  public static String getSDKVersion()
  {
    return Build.VERSION.RELEASE;
  }

  private static TelephonyManager getTelephonyManager(Context paramContext)
  {
    try
    {
      TelephonyManager localTelephonyManager = (TelephonyManager)paramContext.getSystemService("phone");
      return localTelephonyManager;
    }
    catch (SecurityException localSecurityException)
    {
      Log.e("JtAd", "JtAdManager.getTelephonyManager: " + localSecurityException.getMessage());
    }
    return null;
  }

  public static void removePreferences(Context paramContext, String paramString)
  {
    SharedPreferences.Editor localEditor = paramContext.getSharedPreferences("jtPref", 0).edit();
    localEditor.remove(paramString);
    localEditor.commit();
  }

  public static void savePreferences(Context paramContext, String paramString1, String paramString2)
  {
    SharedPreferences.Editor localEditor = paramContext.getSharedPreferences("jtPref", 0).edit();
    localEditor.putString(paramString1, paramString2);
    localEditor.commit();
  }

  public boolean isTestMode()
  {
    return this.testMode;
  }

  public void setTestMode(boolean paramBoolean)
  {
    this.testMode = paramBoolean;
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.jumptap.adtag.utils.JtAdManager
 * JD-Core Version:    0.6.2
 */